import { createSlice } from "@reduxjs/toolkit";
import store from 'store2'
const appSlice = createSlice({
    name: 'appslice',
    initialState: {
        collapsed: store.get('collapsed') === true,
        tourGuide: store.get('tourGuide') === true,
        themeColor: store.get('themeColor') === true,
        themeMotion: store.get('themeMotion')===true,
    },
    reducers: {
        setCollapsed(state, action) {
            store.set('collapsed', action.payload)
            state.collapsed = store.get('collapsed')
        },
        setTourGuide(state, action) {
            store.set('tourGuide', action.payload)
            state.tourGuide = store.get('tourGuide')
        },
        setThemeColor(state, action) {
            store.set('themeColor', action.payload)
            state.themeColor = store.get('themeColor')
        },
        setThemeMotion(state, action) {
            store.set('themeMotion', action.payload)
            state.themeMotion = store.get('themeMotion')
        },
    }
})


export const { setCollapsed, setTourGuide, setThemeColor, setThemeMotion } = appSlice.actions;
export default appSlice.reducer;